#include "ThreadPool.hpp"

#include <functional>
#include <iostream>
#include <unistd.h>
using std::cout;
using std::endl;
using std::function;

void func(){
    static int num = 0;
    cout << "run func for " << num << " times" <<endl;
    num++;
    sleep(1);
}

int main()
{
    tp::ThreadPool threadpool(10,3);
    threadpool.start();
    
    for(int i = 0; i < 20; ++i){
        threadpool.addTask(std::bind(func));
        cout << "main: add "<< i << endl;
    }
    
    threadpool.stop();

    return 0;
}

